package com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.javasm.common.R;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.entity.GgBrand;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.service.GgBrandService;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.vo.BrandVo;
import com.javasm.mb_store_api_final.giftsandgoods.goodsType.entity.GgGoodsType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lh
 * @version 0.1
 * @className GoodsBrandController
 * @date 2024/8/4 21:29
 * @description
 * @since jdk11
 */
@RestController
@RequestMapping("/goodsBrand")
public class GoodsBrandController {
    @Resource
    GgBrandService goodsBrandService;
    //查询品牌列表
    @RequestMapping("/list")
    public R list(@RequestBody BrandVo brandVo) {
        IPage<GgBrand> page = goodsBrandService.listByBrandName(brandVo);
        return R.ok(page);
    }
    //添加品牌
    @RequestMapping("/addBrand")
    public R addBrand(@RequestBody GgBrand brand) {
        boolean b = goodsBrandService.save(brand);
        return R.ok(b);
    }
    //删除品牌
    @RequestMapping("/deleteBrand")
    public R deleteBrand(@RequestBody GgBrand brand) {
        boolean b = goodsBrandService.removeById(brand.getId());
        return R.ok(b);
    }
    //根据id查询品牌
    @RequestMapping("/getById")
    public R getById(@RequestBody GgBrand brand) {
        GgBrand byId = goodsBrandService.getById(brand.getId());
        return R.ok(byId);
    }
    //修改品牌
    @RequestMapping("/updateBrand")
    public R updateBrand(@RequestBody GgBrand brand) {
        boolean b = goodsBrandService.updateById(brand);
        return R.ok(b);
    }
}
